import {takeEvery, put} from 'redux-saga/effects'
import {GET_MY_LIST} from './actionTypes'
import axios from 'axios'
import {getListAction} from './actionFactory'

// generator
function* mySaga(){
  yield takeEvery(GET_MY_LIST, getList)
}

function* getList(){
  const res = yield axios.get('https://easy-mock.com/mock/5dd3811b7e157d38e7e4107c/react-learn/todoList')
  const action = getListAction(res.data)
  yield put(action)
}

export default mySaga